use warnings;
use Test::More 'no_plan';
use Inline C;

#1
is(buf_init_t(), 0, 'initialize the buf.');
is(buf_alloc_t(1), 0, 'alloc a block from the buf.');
is(buf_alloc_t(0), 0, 'alloc a block from the buf.');
is(buf_alloc_t(1), 0, 'alloc a block from the buf.');
is(buf_alloc_t(0), 0, 'alloc a block from the buf.');
is(buf_alloc_t(1), 0, 'alloc a block from the buf.');
is(buf_alloc_t(0), 0, 'alloc a block from the buf.');
is(buf_alloc_t(1), 0, 'alloc a block from the buf.');
is(buf_alloc_t(0), 0, 'alloc a block from the buf.');
is(buf_alloc_t(1), 0, 'alloc a block from the buf.');

#11
is(buf_alloc_t(0), 0, 'alloc a block from the buf.');
# now the buf is emtpy, namely no space.
# so the next test should fail.
isnt(buf_alloc_t(0), 0, 'alloc a block from the buf.');
# reinitialize the buf again to test free.
is(buf_init_t(), 0, 'reinitialize the buf.');


is(buf_alloc_t(0), 0, 'alloc a block from the buf.');
is(buf_free_t(), 0, 'free a block from the buf.');
# now no alocated block, so the next free test should fail.
isnt(buf_free_t(), 0, 'free a block from the buf.');
is(buf_alloc_t(0), 0, 'alloc a block from the buf.');
is(buf_free_t(), 0, 'free a block from the buf.');
isnt(buf_free_t(), 0, 'free a block from the buf.');

# reinitialize the buf again to test free.
buf_init_t();
isnt(buf_free_t(), 0, 'free a block from the buf.');

__END__
__C__

#include "buf_test.c"
#include "../../../../mac/buf.c"
#include "../../../../mac/list.c"
#include "../../../../mac/mem.c"

int buf_init_t()
{
    return buf_init_test();
}

int buf_alloc_t(unsigned char is_trx)
{
    return buf_alloc_test(is_trx);
}

int buf_free_t()
{
    return buf_free_test();
}


